//
//@File    :	8.15_choices.cpp
//@Time    :	2021/08/22 11:37:44
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	choosing a template
//

#include <iostream>

using namespace std;

template <typename T>//返回较小值
T lesser(T a,T b)
{
    return a<b?a:b;
}
int lesser(int a,int b)//返回绝对值较小的
{
    a=a<0?-a:a;
    b=b<0?-b:b;
    return a<b?a:b;
}
int main()
{
    int m=20;
    int n=-30;
    double x=15.5;
    double y=25.9;

    cout<<lesser(m,n)<<endl;//返回20
    cout<<lesser(x,y)<<endl;//返回15.5
    cout<<lesser<>(m,n)<<endl;//返回-30
    cout<<lesser<int>(x,y)<<endl;//返回15

    system("pause");
    return 0;
}